<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
-----------------------------------------------------------------------------
--
-- (c) The University of Glasgow 2015
--
-- ELF format tools
--
-----------------------------------------------------------------------------
-}</span><span>
</span><span id="line-10"></span><span>
</span><span id="line-11"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.SysTools.Elf</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-12"></span><span>    </span><span class="annot"><a href="GHC.SysTools.Elf.html#readElfSectionByName"><span class="hs-identifier">readElfSectionByName</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-13"></span><span>    </span><span class="annot"><a href="GHC.SysTools.Elf.html#readElfNoteAsString"><span class="hs-identifier">readElfNoteAsString</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-14"></span><span>    </span><span class="annot"><a href="GHC.SysTools.Elf.html#makeElfNote"><span class="hs-identifier">makeElfNote</span></a></span><span>
</span><span id="line-15"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-16"></span><span>
</span><span id="line-17"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Asm.html"><span class="hs-identifier">GHC.Utils.Asm</span></a></span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Exception.html"><span class="hs-identifier">GHC.Utils.Exception</span></a></span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#"><span class="hs-identifier">GHC.Platform</span></a></span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html"><span class="hs-identifier">GHC.Utils.Error</span></a></span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html"><span class="hs-identifier">GHC.Data.Maybe</span></a></span><span>       </span><span class="hs-special">(</span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier">MaybeT</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#runMaybeT"><span class="hs-identifier">runMaybeT</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>       </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Misc.html#charToC"><span class="hs-identifier">charToC</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier">text</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Utils.Outputable.html#hcat"><span class="hs-identifier">hcat</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier">SDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier">when</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../binary/src/Data.Binary.Get.html#"><span class="hs-identifier">Data.Binary.Get</span></a></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Word.html#"><span class="hs-identifier">Data.Word</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Char.html#"><span class="hs-identifier">Data.Char</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#ord"><span class="hs-identifier">ord</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.html#"><span class="hs-identifier">Data.ByteString.Lazy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier">ByteString</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.html#"><span class="hs-identifier">Data.ByteString.Lazy</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">LBS</span></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Char8.html#"><span class="hs-identifier">Data.ByteString.Lazy.Char8</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">B8</span></span><span>
</span><span id="line-35"></span><span>
</span><span id="line-36"></span><span class="hs-comment">{- Note [ELF specification]
   ~~~~~~~~~~~~~~~~~~~~~~~~

   ELF (Executable and Linking Format) is described in the System V Application
   Binary Interface (or ABI). The latter is composed of two parts: a generic
   part and a processor specific part. The generic ABI describes the parts of
   the interface that remain constant across all hardware implementations of
   System V.

   The latest release of the specification of the generic ABI is the version
   4.1 from March 18, 1997:

     - http://www.sco.com/developers/devspecs/gabi41.pdf

   Since 1997, snapshots of the draft for the &quot;next&quot; version are published:

     - http://www.sco.com/developers/gabi/

   Quoting the notice on the website: &quot;There is more than one instance of these
   chapters to permit references to older instances to remain valid. All
   modifications to these chapters are forward-compatible, so that correct use
   of an older specification will not be invalidated by a newer instance.
   Approximately on a yearly basis, a new instance will be saved, as it reaches
   what appears to be a stable state.&quot;

   Nevertheless we will see that since 1998 it is not true for Note sections.

   Many ELF sections
   -----------------

   ELF-4.1: the normal section number fields in ELF are limited to 16 bits,
   which runs out of bits when you try to cram in more sections than that. Two
   fields are concerned: the one containing the number of the sections and the
   one containing the index of the section that contains section's names. (The
   same thing applies to the field containing the number of segments, but we
   don't care about it here).

   ELF-next: to solve this, theses fields in the ELF header have an escape
   value (different for each case), and the actual section number is stashed
   into unused fields in the first section header.

   We support this extension as it is forward-compatible with ELF-4.1.
   Moreover, GHC may generate objects with a lot of sections with the
   &quot;function-sections&quot; feature (one section per function).

   Note sections
   -------------

   Sections with type &quot;note&quot; (SHT_NOTE in the specification) are used to add
   arbitrary data into an ELF file. An entry in a note section is composed of a
   name, a type and a value.

   ELF-4.1: &quot;The note information in sections and program header elements holds
   any number of entries, each of which is an array of 4-byte words in the
   format of the target processor.&quot; Each entry has the following format:
         | namesz |   Word32: size of the name string (including the ending \0)
         | descsz |   Word32: size of the value
         |  type  |   Word32: type of the note
         |  name  |   Name string (with \0 padding to ensure 4-byte alignment)
         |  ...   |
         |  desc  |   Value (with \0 padding to ensure 4-byte alignment)
         |  ...   |

   ELF-next: &quot;The note information in sections and program header elements
   holds a variable amount of entries. In 64-bit objects (files with
   e_ident[EI_CLASS] equal to ELFCLASS64), each entry is an array of 8-byte
   words in the format of the target processor. In 32-bit objects (files with
   e_ident[EI_CLASS] equal to ELFCLASS32), each entry is an array of 4-byte
   words in the format of the target processor.&quot; (from 1998-2015 snapshots)

   This is not forward-compatible with ELF-4.1. In practice, for almost all
   platforms namesz, descz and type fields are 4-byte words for both 32-bit and
   64-bit objects (see elf.h and readelf source code).

   The only exception in readelf source code is for IA_64 machines with OpenVMS
   OS: &quot;This OS has so many departures from the ELF standard that we test it at
   many places&quot; (comment for is_ia64_vms() in readelf.c). In this case, namesz,
   descsz and type fields are 8-byte words and name and value fields are padded
   to ensure 8-byte alignment.

   We don't support this platform in the following code. Reading a note section
   could be done easily (by testing Machine and OS fields in the ELF header).
   Writing a note section, however, requires that we generate a different
   assembly code for GAS depending on the target platform and this is a little
   bit more involved.

-}</span><span>
</span><span id="line-123"></span><span>
</span><span id="line-124"></span><span>
</span><span id="line-125"></span><span class="hs-comment">-- | ELF header</span><span>
</span><span id="line-126"></span><span class="hs-comment">--</span><span>
</span><span id="line-127"></span><span class="hs-comment">-- The ELF header indicates the native word size (32-bit or 64-bit) and the</span><span>
</span><span id="line-128"></span><span class="hs-comment">-- endianness of the target machine. We directly store getters for words of</span><span>
</span><span id="line-129"></span><span class="hs-comment">-- different sizes as it is more convenient to use. We also store the word size</span><span>
</span><span id="line-130"></span><span class="hs-comment">-- as it is useful to skip some uninteresting fields.</span><span>
</span><span id="line-131"></span><span class="hs-comment">--</span><span>
</span><span id="line-132"></span><span class="hs-comment">-- Other information such as the target machine and OS are left out as we don't</span><span>
</span><span id="line-133"></span><span class="hs-comment">-- use them yet. We could add them in the future if we ever need them.</span><span>
</span><span id="line-134"></span><span class="hs-keyword">data</span><span> </span><span id="ElfHeader"><span class="annot"><a href="GHC.SysTools.Elf.html#ElfHeader"><span class="hs-identifier hs-var">ElfHeader</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="ElfHeader"><span class="annot"><a href="GHC.SysTools.Elf.html#ElfHeader"><span class="hs-identifier hs-var">ElfHeader</span></a></span></span><span>
</span><span id="line-135"></span><span>   </span><span class="hs-special">{</span><span> </span><span id="gw16"><span class="annot"><span class="annottext">ElfHeader -&gt; Get Word16
</span><a href="GHC.SysTools.Elf.html#gw16"><span class="hs-identifier hs-var hs-var">gw16</span></a></span></span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../binary/src/Data.Binary.Get.Internal.html#Get"><span class="hs-identifier hs-type">Get</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span>   </span><span class="hs-comment">-- ^ Get a Word16 with the correct endianness</span><span>
</span><span id="line-136"></span><span>   </span><span class="hs-special">,</span><span> </span><span id="gw32"><span class="annot"><span class="annottext">ElfHeader -&gt; Get Word32
</span><a href="GHC.SysTools.Elf.html#gw32"><span class="hs-identifier hs-var hs-var">gw32</span></a></span></span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../binary/src/Data.Binary.Get.Internal.html#Get"><span class="hs-identifier hs-type">Get</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word32"><span class="hs-identifier hs-type">Word32</span></a></span><span>   </span><span class="hs-comment">-- ^ Get a Word32 with the correct endianness</span><span>
</span><span id="line-137"></span><span>   </span><span class="hs-special">,</span><span> </span><span id="gwN"><span class="annot"><span class="annottext">ElfHeader -&gt; Get Word64
</span><a href="GHC.SysTools.Elf.html#gwN"><span class="hs-identifier hs-var hs-var">gwN</span></a></span></span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../binary/src/Data.Binary.Get.Internal.html#Get"><span class="hs-identifier hs-type">Get</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span>   </span><span class="hs-comment">-- ^ Get a Word with the correct word size</span><span>
</span><span id="line-138"></span><span>                              </span><span class="hs-comment">--   and endianness</span><span>
</span><span id="line-139"></span><span>   </span><span class="hs-special">,</span><span> </span><span id="wordSize"><span class="annot"><span class="annottext">ElfHeader -&gt; Int
</span><a href="GHC.SysTools.Elf.html#wordSize"><span class="hs-identifier hs-var hs-var">wordSize</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>          </span><span class="hs-comment">-- ^ Word size in bytes</span><span>
</span><span id="line-140"></span><span>   </span><span class="hs-special">}</span><span>
</span><span id="line-141"></span><span>
</span><span id="line-142"></span><span>
</span><span id="line-143"></span><span class="hs-comment">-- | Read the ELF header</span><span>
</span><span id="line-144"></span><span class="annot"><a href="GHC.SysTools.Elf.html#readElfHeader"><span class="hs-identifier hs-type">readElfHeader</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.SysTools.Elf.html#ElfHeader"><span class="hs-identifier hs-type">ElfHeader</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-145"></span><span id="readElfHeader"><span class="annot"><span class="annottext">readElfHeader :: DynFlags -&gt; ByteString -&gt; IO (Maybe ElfHeader)
</span><a href="GHC.SysTools.Elf.html#readElfHeader"><span class="hs-identifier hs-var hs-var">readElfHeader</span></a></span></span><span> </span><span id="local-6989586621680944296"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944296"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621680944295"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944295"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Get (Maybe ElfHeader) -&gt; ByteString -&gt; IO (Maybe ElfHeader)
forall a. Get a -&gt; ByteString -&gt; IO a
</span><a href="GHC.SysTools.Elf.html#runGetOrThrow"><span class="hs-identifier hs-var">runGetOrThrow</span></a></span><span> </span><span class="annot"><span class="annottext">Get (Maybe ElfHeader)
</span><a href="#local-6989586621680944293"><span class="hs-identifier hs-var">getHeader</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944295"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="annot"><span class="annottext">IO (Maybe ElfHeader)
-&gt; (IOException -&gt; IO (Maybe ElfHeader)) -&gt; IO (Maybe ElfHeader)
forall a. IO a -&gt; (IOException -&gt; IO a) -&gt; IO a
</span><a href="GHC.Utils.Exception.html#catchIO"><span class="hs-operator hs-var">`catchIO`</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">IOException
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-146"></span><span>    </span><span class="annot"><span class="annottext">DynFlags -&gt; Int -&gt; MsgDoc -&gt; IO ()
</span><a href="GHC.Utils.Error.html#debugTraceMsg"><span class="hs-identifier hs-var">debugTraceMsg</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944296"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; IO ()) -&gt; MsgDoc -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-147"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Unable to read ELF header&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-148"></span><span>    </span><span class="annot"><span class="annottext">Maybe ElfHeader -&gt; IO (Maybe ElfHeader)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe ElfHeader
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-149"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-150"></span><span>    </span><span id="local-6989586621680944293"><span class="annot"><span class="annottext">getHeader :: Get (Maybe ElfHeader)
</span><a href="#local-6989586621680944293"><span class="hs-identifier hs-var hs-var">getHeader</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-151"></span><span>      </span><span id="local-6989586621680944238"><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621680944238"><span class="hs-identifier hs-var">magic</span></a></span></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Get Word32
</span><a href="../../binary/src/Data.Binary.Get.html#getWord32be"><span class="hs-identifier hs-var">getWord32be</span></a></span><span>
</span><span id="line-152"></span><span>      </span><span id="local-6989586621680944236"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621680944236"><span class="hs-identifier hs-var">ws</span></a></span></span><span>       </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Get Word8
</span><a href="../../binary/src/Data.Binary.Get.html#getWord8"><span class="hs-identifier hs-var">getWord8</span></a></span><span>
</span><span id="line-153"></span><span>      </span><span id="local-6989586621680944234"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621680944234"><span class="hs-identifier hs-var">endian</span></a></span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Get Word8
</span><a href="../../binary/src/Data.Binary.Get.html#getWord8"><span class="hs-identifier hs-var">getWord8</span></a></span><span>
</span><span id="line-154"></span><span>      </span><span id="local-6989586621680944233"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621680944233"><span class="hs-identifier hs-var">version</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Get Word8
</span><a href="../../binary/src/Data.Binary.Get.html#getWord8"><span class="hs-identifier hs-var">getWord8</span></a></span><span>
</span><span id="line-155"></span><span>      </span><span class="annot"><span class="annottext">Int -&gt; Get ()
</span><a href="../../binary/src/Data.Binary.Get.html#skip"><span class="hs-identifier hs-var">skip</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">9</span></span><span>  </span><span class="hs-comment">-- skip OSABI, ABI version and padding</span><span>
</span><span id="line-156"></span><span>      </span><span class="annot"><span class="annottext">Bool -&gt; Get () -&gt; Get ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621680944238"><span class="hs-identifier hs-var">magic</span></a></span><span> </span><span class="annot"><span class="annottext">Word32 -&gt; Word32 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Word32
</span><span class="hs-number">0x7F454C46</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621680944233"><span class="hs-identifier hs-var">version</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Get () -&gt; Get ()) -&gt; Get () -&gt; Get ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Get ()
forall (m :: * -&gt; *) a. MonadFail m =&gt; String -&gt; m a
</span><a href="../../base/src/Control.Monad.Fail.html#fail"><span class="hs-identifier hs-var">fail</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Invalid ELF header&quot;</span></span><span>
</span><span id="line-157"></span><span>
</span><span id="line-158"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621680944236"><span class="hs-identifier hs-var">ws</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621680944234"><span class="hs-identifier hs-var">endian</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-159"></span><span>          </span><span class="hs-comment">-- ELF 32, little endian</span><span>
</span><span id="line-160"></span><span>          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">1</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe ElfHeader -&gt; Get (Maybe ElfHeader)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe ElfHeader -&gt; Get (Maybe ElfHeader))
-&gt; (ElfHeader -&gt; Maybe ElfHeader)
-&gt; ElfHeader
-&gt; Get (Maybe ElfHeader)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader -&gt; Maybe ElfHeader
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(ElfHeader -&gt; Get (Maybe ElfHeader))
-&gt; ElfHeader -&gt; Get (Maybe ElfHeader)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Get Word16 -&gt; Get Word32 -&gt; Get Word64 -&gt; Int -&gt; ElfHeader
</span><a href="GHC.SysTools.Elf.html#ElfHeader"><span class="hs-identifier hs-var">ElfHeader</span></a></span><span>
</span><span id="line-161"></span><span>                           </span><span class="annot"><span class="annottext">Get Word16
</span><a href="../../binary/src/Data.Binary.Get.html#getWord16le"><span class="hs-identifier hs-var">getWord16le</span></a></span><span>
</span><span id="line-162"></span><span>                           </span><span class="annot"><span class="annottext">Get Word32
</span><a href="../../binary/src/Data.Binary.Get.html#getWord32le"><span class="hs-identifier hs-var">getWord32le</span></a></span><span>
</span><span id="line-163"></span><span>                           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Word32 -&gt; Word64) -&gt; Get Word32 -&gt; Get Word64
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Word32 -&gt; Word64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Get Word32
</span><a href="../../binary/src/Data.Binary.Get.html#getWord32le"><span class="hs-identifier hs-var">getWord32le</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">4</span></span><span>
</span><span id="line-164"></span><span>          </span><span class="hs-comment">-- ELF 32, big endian</span><span>
</span><span id="line-165"></span><span>          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">1</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">2</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe ElfHeader -&gt; Get (Maybe ElfHeader)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe ElfHeader -&gt; Get (Maybe ElfHeader))
-&gt; (ElfHeader -&gt; Maybe ElfHeader)
-&gt; ElfHeader
-&gt; Get (Maybe ElfHeader)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader -&gt; Maybe ElfHeader
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(ElfHeader -&gt; Get (Maybe ElfHeader))
-&gt; ElfHeader -&gt; Get (Maybe ElfHeader)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Get Word16 -&gt; Get Word32 -&gt; Get Word64 -&gt; Int -&gt; ElfHeader
</span><a href="GHC.SysTools.Elf.html#ElfHeader"><span class="hs-identifier hs-var">ElfHeader</span></a></span><span>
</span><span id="line-166"></span><span>                           </span><span class="annot"><span class="annottext">Get Word16
</span><a href="../../binary/src/Data.Binary.Get.html#getWord16be"><span class="hs-identifier hs-var">getWord16be</span></a></span><span>
</span><span id="line-167"></span><span>                           </span><span class="annot"><span class="annottext">Get Word32
</span><a href="../../binary/src/Data.Binary.Get.html#getWord32be"><span class="hs-identifier hs-var">getWord32be</span></a></span><span>
</span><span id="line-168"></span><span>                           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Word32 -&gt; Word64) -&gt; Get Word32 -&gt; Get Word64
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Word32 -&gt; Word64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Get Word32
</span><a href="../../binary/src/Data.Binary.Get.html#getWord32be"><span class="hs-identifier hs-var">getWord32be</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">4</span></span><span>
</span><span id="line-169"></span><span>          </span><span class="hs-comment">-- ELF 64, little endian</span><span>
</span><span id="line-170"></span><span>          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">2</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe ElfHeader -&gt; Get (Maybe ElfHeader)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe ElfHeader -&gt; Get (Maybe ElfHeader))
-&gt; (ElfHeader -&gt; Maybe ElfHeader)
-&gt; ElfHeader
-&gt; Get (Maybe ElfHeader)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader -&gt; Maybe ElfHeader
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(ElfHeader -&gt; Get (Maybe ElfHeader))
-&gt; ElfHeader -&gt; Get (Maybe ElfHeader)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Get Word16 -&gt; Get Word32 -&gt; Get Word64 -&gt; Int -&gt; ElfHeader
</span><a href="GHC.SysTools.Elf.html#ElfHeader"><span class="hs-identifier hs-var">ElfHeader</span></a></span><span>
</span><span id="line-171"></span><span>                           </span><span class="annot"><span class="annottext">Get Word16
</span><a href="../../binary/src/Data.Binary.Get.html#getWord16le"><span class="hs-identifier hs-var">getWord16le</span></a></span><span>
</span><span id="line-172"></span><span>                           </span><span class="annot"><span class="annottext">Get Word32
</span><a href="../../binary/src/Data.Binary.Get.html#getWord32le"><span class="hs-identifier hs-var">getWord32le</span></a></span><span>
</span><span id="line-173"></span><span>                           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Word64 -&gt; Word64) -&gt; Get Word64 -&gt; Get Word64
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; Word64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Get Word64
</span><a href="../../binary/src/Data.Binary.Get.html#getWord64le"><span class="hs-identifier hs-var">getWord64le</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">8</span></span><span>
</span><span id="line-174"></span><span>          </span><span class="hs-comment">-- ELF 64, big endian</span><span>
</span><span id="line-175"></span><span>          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">2</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">2</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe ElfHeader -&gt; Get (Maybe ElfHeader)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe ElfHeader -&gt; Get (Maybe ElfHeader))
-&gt; (ElfHeader -&gt; Maybe ElfHeader)
-&gt; ElfHeader
-&gt; Get (Maybe ElfHeader)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader -&gt; Maybe ElfHeader
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(ElfHeader -&gt; Get (Maybe ElfHeader))
-&gt; ElfHeader -&gt; Get (Maybe ElfHeader)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Get Word16 -&gt; Get Word32 -&gt; Get Word64 -&gt; Int -&gt; ElfHeader
</span><a href="GHC.SysTools.Elf.html#ElfHeader"><span class="hs-identifier hs-var">ElfHeader</span></a></span><span>
</span><span id="line-176"></span><span>                           </span><span class="annot"><span class="annottext">Get Word16
</span><a href="../../binary/src/Data.Binary.Get.html#getWord16be"><span class="hs-identifier hs-var">getWord16be</span></a></span><span>
</span><span id="line-177"></span><span>                           </span><span class="annot"><span class="annottext">Get Word32
</span><a href="../../binary/src/Data.Binary.Get.html#getWord32be"><span class="hs-identifier hs-var">getWord32be</span></a></span><span>
</span><span id="line-178"></span><span>                           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Word64 -&gt; Word64) -&gt; Get Word64 -&gt; Get Word64
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; Word64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Get Word64
</span><a href="../../binary/src/Data.Binary.Get.html#getWord64be"><span class="hs-identifier hs-var">getWord64be</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">8</span></span><span>
</span><span id="line-179"></span><span>          </span><span class="annot"><span class="annottext">(Word8, Word8)
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; Get (Maybe ElfHeader)
forall (m :: * -&gt; *) a. MonadFail m =&gt; String -&gt; m a
</span><a href="../../base/src/Control.Monad.Fail.html#fail"><span class="hs-identifier hs-var">fail</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Invalid ELF header&quot;</span></span><span>
</span><span id="line-180"></span><span>
</span><span id="line-181"></span><span>
</span><span id="line-182"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-183"></span><span class="hs-comment">-- SECTIONS</span><span>
</span><span id="line-184"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-185"></span><span>
</span><span id="line-186"></span><span>
</span><span id="line-187"></span><span class="hs-comment">-- | Description of the section table</span><span>
</span><span id="line-188"></span><span class="hs-keyword">data</span><span> </span><span id="SectionTable"><span class="annot"><a href="GHC.SysTools.Elf.html#SectionTable"><span class="hs-identifier hs-var">SectionTable</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="SectionTable"><span class="annot"><a href="GHC.SysTools.Elf.html#SectionTable"><span class="hs-identifier hs-var">SectionTable</span></a></span></span><span>
</span><span id="line-189"></span><span>  </span><span class="hs-special">{</span><span> </span><span id="sectionTableOffset"><span class="annot"><span class="annottext">SectionTable -&gt; Word64
</span><a href="GHC.SysTools.Elf.html#sectionTableOffset"><span class="hs-identifier hs-var hs-var">sectionTableOffset</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span>  </span><span class="hs-comment">-- ^ offset of the table describing sections</span><span>
</span><span id="line-190"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="sectionEntrySize"><span class="annot"><span class="annottext">SectionTable -&gt; Word16
</span><a href="GHC.SysTools.Elf.html#sectionEntrySize"><span class="hs-identifier hs-var hs-var">sectionEntrySize</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span>  </span><span class="hs-comment">-- ^ size of an entry in the section table</span><span>
</span><span id="line-191"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="sectionEntryCount"><span class="annot"><span class="annottext">SectionTable -&gt; Word64
</span><a href="GHC.SysTools.Elf.html#sectionEntryCount"><span class="hs-identifier hs-var hs-var">sectionEntryCount</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span>  </span><span class="hs-comment">-- ^ number of sections</span><span>
</span><span id="line-192"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="sectionNameIndex"><span class="annot"><span class="annottext">SectionTable -&gt; Word32
</span><a href="GHC.SysTools.Elf.html#sectionNameIndex"><span class="hs-identifier hs-var hs-var">sectionNameIndex</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word32"><span class="hs-identifier hs-type">Word32</span></a></span><span>  </span><span class="hs-comment">-- ^ index of a special section which</span><span>
</span><span id="line-193"></span><span>                                  </span><span class="hs-comment">--   contains section's names</span><span>
</span><span id="line-194"></span><span>  </span><span class="hs-special">}</span><span>
</span><span id="line-195"></span><span>
</span><span id="line-196"></span><span class="hs-comment">-- | Read the ELF section table</span><span>
</span><span id="line-197"></span><span class="annot"><a href="GHC.SysTools.Elf.html#readElfSectionTable"><span class="hs-identifier hs-type">readElfSectionTable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-198"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.SysTools.Elf.html#ElfHeader"><span class="hs-identifier hs-type">ElfHeader</span></a></span><span>
</span><span id="line-199"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-200"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.SysTools.Elf.html#SectionTable"><span class="hs-identifier hs-type">SectionTable</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-201"></span><span>
</span><span id="line-202"></span><span id="readElfSectionTable"><span class="annot"><span class="annottext">readElfSectionTable :: DynFlags -&gt; ElfHeader -&gt; ByteString -&gt; IO (Maybe SectionTable)
</span><a href="GHC.SysTools.Elf.html#readElfSectionTable"><span class="hs-identifier hs-var hs-var">readElfSectionTable</span></a></span></span><span> </span><span id="local-6989586621680944217"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944217"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621680944216"><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944216"><span class="hs-identifier hs-var">hdr</span></a></span></span><span> </span><span id="local-6989586621680944215"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944215"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO (Maybe SectionTable)
</span><a href="#local-6989586621680944214"><span class="hs-identifier hs-var">action</span></a></span><span> </span><span class="annot"><span class="annottext">IO (Maybe SectionTable)
-&gt; (IOException -&gt; IO (Maybe SectionTable))
-&gt; IO (Maybe SectionTable)
forall a. IO a -&gt; (IOException -&gt; IO a) -&gt; IO a
</span><a href="GHC.Utils.Exception.html#catchIO"><span class="hs-operator hs-var">`catchIO`</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">IOException
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-203"></span><span>    </span><span class="annot"><span class="annottext">DynFlags -&gt; Int -&gt; MsgDoc -&gt; IO ()
</span><a href="GHC.Utils.Error.html#debugTraceMsg"><span class="hs-identifier hs-var">debugTraceMsg</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944217"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; IO ()) -&gt; MsgDoc -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-204"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Unable to read ELF section table&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-205"></span><span>    </span><span class="annot"><span class="annottext">Maybe SectionTable -&gt; IO (Maybe SectionTable)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe SectionTable
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-206"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-207"></span><span>    </span><span class="annot"><a href="#local-6989586621680944213"><span class="hs-identifier hs-type">getSectionTable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../binary/src/Data.Binary.Get.Internal.html#Get"><span class="hs-identifier hs-type">Get</span></a></span><span> </span><span class="annot"><a href="GHC.SysTools.Elf.html#SectionTable"><span class="hs-identifier hs-type">SectionTable</span></a></span><span>
</span><span id="line-208"></span><span>    </span><span id="local-6989586621680944213"><span class="annot"><span class="annottext">getSectionTable :: Get SectionTable
</span><a href="#local-6989586621680944213"><span class="hs-identifier hs-var hs-var">getSectionTable</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-209"></span><span>      </span><span class="annot"><span class="annottext">Int -&gt; Get ()
</span><a href="../../binary/src/Data.Binary.Get.html#skip"><span class="hs-identifier hs-var">skip</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">24</span></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span class="annot"><span class="annottext">ElfHeader -&gt; Int
</span><a href="GHC.SysTools.Elf.html#wordSize"><span class="hs-identifier hs-var hs-var">wordSize</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944216"><span class="hs-identifier hs-var">hdr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- skip header and some other fields</span><span>
</span><span id="line-210"></span><span>      </span><span id="local-6989586621680944210"><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621680944210"><span class="hs-identifier hs-var">secTableOffset</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ElfHeader -&gt; Get Word64
</span><a href="GHC.SysTools.Elf.html#gwN"><span class="hs-identifier hs-var hs-var">gwN</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944216"><span class="hs-identifier hs-var">hdr</span></a></span><span>
</span><span id="line-211"></span><span>      </span><span class="annot"><span class="annottext">Int -&gt; Get ()
</span><a href="../../binary/src/Data.Binary.Get.html#skip"><span class="hs-identifier hs-var">skip</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">10</span></span><span>
</span><span id="line-212"></span><span>      </span><span id="local-6989586621680944209"><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621680944209"><span class="hs-identifier hs-var">entrySize</span></a></span></span><span>      </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ElfHeader -&gt; Get Word16
</span><a href="GHC.SysTools.Elf.html#gw16"><span class="hs-identifier hs-var hs-var">gw16</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944216"><span class="hs-identifier hs-var">hdr</span></a></span><span>
</span><span id="line-213"></span><span>      </span><span id="local-6989586621680944208"><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621680944208"><span class="hs-identifier hs-var">entryCount</span></a></span></span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ElfHeader -&gt; Get Word16
</span><a href="GHC.SysTools.Elf.html#gw16"><span class="hs-identifier hs-var hs-var">gw16</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944216"><span class="hs-identifier hs-var">hdr</span></a></span><span>
</span><span id="line-214"></span><span>      </span><span id="local-6989586621680944207"><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621680944207"><span class="hs-identifier hs-var">secNameIndex</span></a></span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ElfHeader -&gt; Get Word16
</span><a href="GHC.SysTools.Elf.html#gw16"><span class="hs-identifier hs-var hs-var">gw16</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944216"><span class="hs-identifier hs-var">hdr</span></a></span><span>
</span><span id="line-215"></span><span>      </span><span class="annot"><span class="annottext">SectionTable -&gt; Get SectionTable
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word64 -&gt; Word16 -&gt; Word64 -&gt; Word32 -&gt; SectionTable
</span><a href="GHC.SysTools.Elf.html#SectionTable"><span class="hs-identifier hs-var">SectionTable</span></a></span><span> </span><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621680944210"><span class="hs-identifier hs-var">secTableOffset</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621680944209"><span class="hs-identifier hs-var">entrySize</span></a></span><span>
</span><span id="line-216"></span><span>                           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word16 -&gt; Word64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621680944208"><span class="hs-identifier hs-var">entryCount</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-217"></span><span>                           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word16 -&gt; Word32
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621680944207"><span class="hs-identifier hs-var">secNameIndex</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-218"></span><span>
</span><span id="line-219"></span><span>    </span><span id="local-6989586621680944214"><span class="annot"><span class="annottext">action :: IO (Maybe SectionTable)
</span><a href="#local-6989586621680944214"><span class="hs-identifier hs-var hs-var">action</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-220"></span><span>      </span><span id="local-6989586621680944195"><span class="annot"><span class="annottext">SectionTable
</span><a href="#local-6989586621680944195"><span class="hs-identifier hs-var">secTable</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Get SectionTable -&gt; ByteString -&gt; IO SectionTable
forall a. Get a -&gt; ByteString -&gt; IO a
</span><a href="GHC.SysTools.Elf.html#runGetOrThrow"><span class="hs-identifier hs-var">runGetOrThrow</span></a></span><span> </span><span class="annot"><span class="annottext">Get SectionTable
</span><a href="#local-6989586621680944213"><span class="hs-identifier hs-var">getSectionTable</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944215"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-221"></span><span>      </span><span class="hs-comment">-- In some cases, the number of entries and the index of the section</span><span>
</span><span id="line-222"></span><span>      </span><span class="hs-comment">-- containing section's names must be found in unused fields of the first</span><span>
</span><span id="line-223"></span><span>      </span><span class="hs-comment">-- section entry (see Note [ELF specification])</span><span>
</span><span id="line-224"></span><span>      </span><span class="hs-keyword">let</span><span>
</span><span id="line-225"></span><span>        </span><span id="local-6989586621680944184"><span class="annot"><span class="annottext">offSize0 :: Int64
</span><a href="#local-6989586621680944184"><span class="hs-identifier hs-var hs-var">offSize0</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; Int64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Word64 -&gt; Int64) -&gt; Word64 -&gt; Int64
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SectionTable -&gt; Word64
</span><a href="GHC.SysTools.Elf.html#sectionTableOffset"><span class="hs-identifier hs-var hs-var">sectionTableOffset</span></a></span><span> </span><span class="annot"><span class="annottext">SectionTable
</span><a href="#local-6989586621680944195"><span class="hs-identifier hs-var">secTable</span></a></span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; Word64 -&gt; Word64
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Word64
</span><span class="hs-number">8</span></span><span>
</span><span id="line-226"></span><span>                                  </span><span class="annot"><span class="annottext">Word64 -&gt; Word64 -&gt; Word64
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Word64
</span><span class="hs-number">3</span></span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; Word64 -&gt; Word64
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Word64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElfHeader -&gt; Int
</span><a href="GHC.SysTools.Elf.html#wordSize"><span class="hs-identifier hs-var hs-var">wordSize</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944216"><span class="hs-identifier hs-var">hdr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-227"></span><span>        </span><span id="local-6989586621680944177"><span class="annot"><span class="annottext">offLink0 :: Int64
</span><a href="#local-6989586621680944177"><span class="hs-identifier hs-var hs-var">offLink0</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int64 -&gt; Int64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Int64 -&gt; Int64) -&gt; Int64 -&gt; Int64
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int64
</span><a href="#local-6989586621680944184"><span class="hs-identifier hs-var">offSize0</span></a></span><span> </span><span class="annot"><span class="annottext">Int64 -&gt; Int64 -&gt; Int64
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElfHeader -&gt; Int
</span><a href="GHC.SysTools.Elf.html#wordSize"><span class="hs-identifier hs-var hs-var">wordSize</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944216"><span class="hs-identifier hs-var">hdr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-228"></span><span>
</span><span id="line-229"></span><span>      </span><span id="local-6989586621680944176"><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621680944176"><span class="hs-identifier hs-var">entryCount'</span></a></span></span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">SectionTable -&gt; Word64
</span><a href="GHC.SysTools.Elf.html#sectionEntryCount"><span class="hs-identifier hs-var hs-var">sectionEntryCount</span></a></span><span> </span><span class="annot"><span class="annottext">SectionTable
</span><a href="#local-6989586621680944195"><span class="hs-identifier hs-var">secTable</span></a></span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; Word64 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Word64
</span><span class="hs-number">0</span></span><span>
</span><span id="line-230"></span><span>                          </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; IO Word64
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SectionTable -&gt; Word64
</span><a href="GHC.SysTools.Elf.html#sectionEntryCount"><span class="hs-identifier hs-var hs-var">sectionEntryCount</span></a></span><span> </span><span class="annot"><span class="annottext">SectionTable
</span><a href="#local-6989586621680944195"><span class="hs-identifier hs-var">secTable</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-231"></span><span>                          </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Get Word64 -&gt; ByteString -&gt; IO Word64
forall a. Get a -&gt; ByteString -&gt; IO a
</span><a href="GHC.SysTools.Elf.html#runGetOrThrow"><span class="hs-identifier hs-var">runGetOrThrow</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElfHeader -&gt; Get Word64
</span><a href="GHC.SysTools.Elf.html#gwN"><span class="hs-identifier hs-var hs-var">gwN</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944216"><span class="hs-identifier hs-var">hdr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int64 -&gt; ByteString -&gt; ByteString
</span><a href="../../bytestring/src/Data.ByteString.Lazy.html#drop"><span class="hs-identifier hs-var">LBS.drop</span></a></span><span> </span><span class="annot"><span class="annottext">Int64
</span><a href="#local-6989586621680944184"><span class="hs-identifier hs-var">offSize0</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944215"><span class="hs-identifier hs-var">bs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-232"></span><span>      </span><span id="local-6989586621680944174"><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621680944174"><span class="hs-identifier hs-var">entryNameIndex'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">SectionTable -&gt; Word32
</span><a href="GHC.SysTools.Elf.html#sectionNameIndex"><span class="hs-identifier hs-var hs-var">sectionNameIndex</span></a></span><span> </span><span class="annot"><span class="annottext">SectionTable
</span><a href="#local-6989586621680944195"><span class="hs-identifier hs-var">secTable</span></a></span><span> </span><span class="annot"><span class="annottext">Word32 -&gt; Word32 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Word32
</span><span class="hs-number">0xffff</span></span><span>
</span><span id="line-233"></span><span>                          </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Word32 -&gt; IO Word32
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SectionTable -&gt; Word32
</span><a href="GHC.SysTools.Elf.html#sectionNameIndex"><span class="hs-identifier hs-var hs-var">sectionNameIndex</span></a></span><span> </span><span class="annot"><span class="annottext">SectionTable
</span><a href="#local-6989586621680944195"><span class="hs-identifier hs-var">secTable</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-234"></span><span>                          </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Get Word32 -&gt; ByteString -&gt; IO Word32
forall a. Get a -&gt; ByteString -&gt; IO a
</span><a href="GHC.SysTools.Elf.html#runGetOrThrow"><span class="hs-identifier hs-var">runGetOrThrow</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElfHeader -&gt; Get Word32
</span><a href="GHC.SysTools.Elf.html#gw32"><span class="hs-identifier hs-var hs-var">gw32</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944216"><span class="hs-identifier hs-var">hdr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int64 -&gt; ByteString -&gt; ByteString
</span><a href="../../bytestring/src/Data.ByteString.Lazy.html#drop"><span class="hs-identifier hs-var">LBS.drop</span></a></span><span> </span><span class="annot"><span class="annottext">Int64
</span><a href="#local-6989586621680944177"><span class="hs-identifier hs-var">offLink0</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944215"><span class="hs-identifier hs-var">bs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-235"></span><span>      </span><span class="annot"><span class="annottext">Maybe SectionTable -&gt; IO (Maybe SectionTable)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SectionTable -&gt; Maybe SectionTable
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(SectionTable -&gt; Maybe SectionTable)
-&gt; SectionTable -&gt; Maybe SectionTable
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SectionTable
</span><a href="#local-6989586621680944195"><span class="hs-identifier hs-var">secTable</span></a></span><span>
</span><span id="line-236"></span><span>        </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sectionEntryCount :: Word64
</span><a href="GHC.SysTools.Elf.html#sectionEntryCount"><span class="hs-identifier hs-var">sectionEntryCount</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621680944176"><span class="hs-identifier hs-var">entryCount'</span></a></span><span>
</span><span id="line-237"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sectionNameIndex :: Word32
</span><a href="GHC.SysTools.Elf.html#sectionNameIndex"><span class="hs-identifier hs-var">sectionNameIndex</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621680944174"><span class="hs-identifier hs-var">entryNameIndex'</span></a></span><span>
</span><span id="line-238"></span><span>        </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-239"></span><span>
</span><span id="line-240"></span><span>
</span><span id="line-241"></span><span class="hs-comment">-- | A section</span><span>
</span><span id="line-242"></span><span class="hs-keyword">data</span><span> </span><span id="Section"><span class="annot"><a href="GHC.SysTools.Elf.html#Section"><span class="hs-identifier hs-var">Section</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="Section"><span class="annot"><a href="GHC.SysTools.Elf.html#Section"><span class="hs-identifier hs-var">Section</span></a></span></span><span>
</span><span id="line-243"></span><span>  </span><span class="hs-special">{</span><span> </span><span id="entryName"><span class="annot"><span class="annottext">Section -&gt; ByteString
</span><a href="GHC.SysTools.Elf.html#entryName"><span class="hs-identifier hs-var hs-var">entryName</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>   </span><span class="hs-comment">-- ^ Name of the section</span><span>
</span><span id="line-244"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="entryBS"><span class="annot"><span class="annottext">Section -&gt; ByteString
</span><a href="GHC.SysTools.Elf.html#entryBS"><span class="hs-identifier hs-var hs-var">entryBS</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>   </span><span class="hs-comment">-- ^ Content of the section</span><span>
</span><span id="line-245"></span><span>  </span><span class="hs-special">}</span><span>
</span><span id="line-246"></span><span>
</span><span id="line-247"></span><span class="hs-comment">-- | Read a ELF section</span><span>
</span><span id="line-248"></span><span class="annot"><a href="GHC.SysTools.Elf.html#readElfSectionByIndex"><span class="hs-identifier hs-type">readElfSectionByIndex</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-249"></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.SysTools.Elf.html#ElfHeader"><span class="hs-identifier hs-type">ElfHeader</span></a></span><span>
</span><span id="line-250"></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.SysTools.Elf.html#SectionTable"><span class="hs-identifier hs-type">SectionTable</span></a></span><span>
</span><span id="line-251"></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span>
</span><span id="line-252"></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-253"></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.SysTools.Elf.html#Section"><span class="hs-identifier hs-type">Section</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-254"></span><span>
</span><span id="line-255"></span><span id="readElfSectionByIndex"><span class="annot"><span class="annottext">readElfSectionByIndex :: DynFlags
-&gt; ElfHeader
-&gt; SectionTable
-&gt; Word64
-&gt; ByteString
-&gt; IO (Maybe Section)
</span><a href="GHC.SysTools.Elf.html#readElfSectionByIndex"><span class="hs-identifier hs-var hs-var">readElfSectionByIndex</span></a></span></span><span> </span><span id="local-6989586621680944169"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944169"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621680944168"><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944168"><span class="hs-identifier hs-var">hdr</span></a></span></span><span> </span><span id="local-6989586621680944167"><span class="annot"><span class="annottext">SectionTable
</span><a href="#local-6989586621680944167"><span class="hs-identifier hs-var">secTable</span></a></span></span><span> </span><span id="local-6989586621680944166"><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621680944166"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span id="local-6989586621680944165"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944165"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO (Maybe Section)
</span><a href="#local-6989586621680944164"><span class="hs-identifier hs-var">action</span></a></span><span> </span><span class="annot"><span class="annottext">IO (Maybe Section)
-&gt; (IOException -&gt; IO (Maybe Section)) -&gt; IO (Maybe Section)
forall a. IO a -&gt; (IOException -&gt; IO a) -&gt; IO a
</span><a href="GHC.Utils.Exception.html#catchIO"><span class="hs-operator hs-var">`catchIO`</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">IOException
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-256"></span><span>    </span><span class="annot"><span class="annottext">DynFlags -&gt; Int -&gt; MsgDoc -&gt; IO ()
</span><a href="GHC.Utils.Error.html#debugTraceMsg"><span class="hs-identifier hs-var">debugTraceMsg</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944169"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; IO ()) -&gt; MsgDoc -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-257"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Unable to read ELF section&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-258"></span><span>    </span><span class="annot"><span class="annottext">Maybe Section -&gt; IO (Maybe Section)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Section
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-259"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-260"></span><span>    </span><span class="hs-comment">-- read an entry from the section table</span><span>
</span><span id="line-261"></span><span>    </span><span id="local-6989586621680944148"><span class="annot"><span class="annottext">getEntry :: Get (Word32, ByteString)
</span><a href="#local-6989586621680944148"><span class="hs-identifier hs-var hs-var">getEntry</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-262"></span><span>      </span><span id="local-6989586621680944147"><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621680944147"><span class="hs-identifier hs-var">nameIndex</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ElfHeader -&gt; Get Word32
</span><a href="GHC.SysTools.Elf.html#gw32"><span class="hs-identifier hs-var hs-var">gw32</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944168"><span class="hs-identifier hs-var">hdr</span></a></span><span>
</span><span id="line-263"></span><span>      </span><span class="annot"><span class="annottext">Int -&gt; Get ()
</span><a href="../../binary/src/Data.Binary.Get.html#skip"><span class="hs-identifier hs-var">skip</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">4</span></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span class="annot"><span class="annottext">ElfHeader -&gt; Int
</span><a href="GHC.SysTools.Elf.html#wordSize"><span class="hs-identifier hs-var hs-var">wordSize</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944168"><span class="hs-identifier hs-var">hdr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-264"></span><span>      </span><span id="local-6989586621680944146"><span class="annot"><span class="annottext">Int64
</span><a href="#local-6989586621680944146"><span class="hs-identifier hs-var">offset</span></a></span></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Word64 -&gt; Int64) -&gt; Get Word64 -&gt; Get Int64
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; Int64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Get Word64 -&gt; Get Int64) -&gt; Get Word64 -&gt; Get Int64
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader -&gt; Get Word64
</span><a href="GHC.SysTools.Elf.html#gwN"><span class="hs-identifier hs-var hs-var">gwN</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944168"><span class="hs-identifier hs-var">hdr</span></a></span><span>
</span><span id="line-265"></span><span>      </span><span id="local-6989586621680944145"><span class="annot"><span class="annottext">Int64
</span><a href="#local-6989586621680944145"><span class="hs-identifier hs-var">size</span></a></span></span><span>      </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Word64 -&gt; Int64) -&gt; Get Word64 -&gt; Get Int64
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; Int64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Get Word64 -&gt; Get Int64) -&gt; Get Word64 -&gt; Get Int64
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader -&gt; Get Word64
</span><a href="GHC.SysTools.Elf.html#gwN"><span class="hs-identifier hs-var hs-var">gwN</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944168"><span class="hs-identifier hs-var">hdr</span></a></span><span>
</span><span id="line-266"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680944144"><span class="annot"><span class="annottext">bs' :: ByteString
</span><a href="#local-6989586621680944144"><span class="hs-identifier hs-var hs-var">bs'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int64 -&gt; ByteString -&gt; ByteString
</span><a href="../../bytestring/src/Data.ByteString.Lazy.html#take"><span class="hs-identifier hs-var">LBS.take</span></a></span><span> </span><span class="annot"><span class="annottext">Int64
</span><a href="#local-6989586621680944145"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int64 -&gt; ByteString -&gt; ByteString
</span><a href="../../bytestring/src/Data.ByteString.Lazy.html#drop"><span class="hs-identifier hs-var">LBS.drop</span></a></span><span> </span><span class="annot"><span class="annottext">Int64
</span><a href="#local-6989586621680944146"><span class="hs-identifier hs-var">offset</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944165"><span class="hs-identifier hs-var">bs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-267"></span><span>      </span><span class="annot"><span class="annottext">(Word32, ByteString) -&gt; Get (Word32, ByteString)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621680944147"><span class="hs-identifier hs-var">nameIndex</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944144"><span class="hs-identifier hs-var">bs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-268"></span><span>
</span><span id="line-269"></span><span>    </span><span class="hs-comment">-- read the entry with the given index in the section table</span><span>
</span><span id="line-270"></span><span>    </span><span id="local-6989586621680944142"><span class="annot"><span class="annottext">getEntryByIndex :: Word64 -&gt; IO (Word32, ByteString)
</span><a href="#local-6989586621680944142"><span class="hs-identifier hs-var hs-var">getEntryByIndex</span></a></span></span><span> </span><span id="local-6989586621680944141"><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621680944141"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Get (Word32, ByteString) -&gt; ByteString -&gt; IO (Word32, ByteString)
forall a. Get a -&gt; ByteString -&gt; IO a
</span><a href="GHC.SysTools.Elf.html#runGetOrThrow"><span class="hs-identifier hs-var">runGetOrThrow</span></a></span><span> </span><span class="annot"><span class="annottext">Get (Word32, ByteString)
</span><a href="#local-6989586621680944148"><span class="hs-identifier hs-var">getEntry</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944140"><span class="hs-identifier hs-var">bs'</span></a></span><span>
</span><span id="line-271"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-272"></span><span>        </span><span id="local-6989586621680944140"><span class="annot"><span class="annottext">bs' :: ByteString
</span><a href="#local-6989586621680944140"><span class="hs-identifier hs-var hs-var">bs'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int64 -&gt; ByteString -&gt; ByteString
</span><a href="../../bytestring/src/Data.ByteString.Lazy.html#drop"><span class="hs-identifier hs-var">LBS.drop</span></a></span><span> </span><span class="annot"><span class="annottext">Int64
</span><a href="#local-6989586621680944139"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944165"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-273"></span><span>        </span><span id="local-6989586621680944139"><span class="annot"><span class="annottext">off :: Int64
</span><a href="#local-6989586621680944139"><span class="hs-identifier hs-var hs-var">off</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; Int64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Word64 -&gt; Int64) -&gt; Word64 -&gt; Int64
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SectionTable -&gt; Word64
</span><a href="GHC.SysTools.Elf.html#sectionTableOffset"><span class="hs-identifier hs-var hs-var">sectionTableOffset</span></a></span><span> </span><span class="annot"><span class="annottext">SectionTable
</span><a href="#local-6989586621680944167"><span class="hs-identifier hs-var">secTable</span></a></span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; Word64 -&gt; Word64
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span>
</span><span id="line-274"></span><span>                             </span><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621680944141"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; Word64 -&gt; Word64
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SectionTable -&gt; Word16
</span><a href="GHC.SysTools.Elf.html#sectionEntrySize"><span class="hs-identifier hs-var hs-var">sectionEntrySize</span></a></span><span> </span><span class="annot"><span class="annottext">SectionTable
</span><a href="#local-6989586621680944167"><span class="hs-identifier hs-var">secTable</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-275"></span><span>
</span><span id="line-276"></span><span>    </span><span class="hs-comment">-- Get the name of a section</span><span>
</span><span id="line-277"></span><span>    </span><span id="local-6989586621680944131"><span class="annot"><span class="annottext">getEntryName :: Int64 -&gt; IO ByteString
</span><a href="#local-6989586621680944131"><span class="hs-identifier hs-var hs-var">getEntryName</span></a></span></span><span> </span><span id="local-6989586621680944130"><span class="annot"><span class="annottext">Int64
</span><a href="#local-6989586621680944130"><span class="hs-identifier hs-var">nameIndex</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-278"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680944127"><span class="annot"><span class="annottext">idx :: Word64
</span><a href="#local-6989586621680944127"><span class="hs-identifier hs-var hs-var">idx</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word32 -&gt; Word64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SectionTable -&gt; Word32
</span><a href="GHC.SysTools.Elf.html#sectionNameIndex"><span class="hs-identifier hs-var hs-var">sectionNameIndex</span></a></span><span> </span><span class="annot"><span class="annottext">SectionTable
</span><a href="#local-6989586621680944167"><span class="hs-identifier hs-var">secTable</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-279"></span><span>      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word32
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621680944126"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944126"><span class="hs-identifier hs-var">nameTable</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; IO (Word32, ByteString)
</span><a href="#local-6989586621680944142"><span class="hs-identifier hs-var">getEntryByIndex</span></a></span><span> </span><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621680944127"><span class="hs-identifier hs-var">idx</span></a></span><span>
</span><span id="line-280"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680944125"><span class="annot"><span class="annottext">bs' :: ByteString
</span><a href="#local-6989586621680944125"><span class="hs-identifier hs-var hs-var">bs'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int64 -&gt; ByteString -&gt; ByteString
</span><a href="../../bytestring/src/Data.ByteString.Lazy.html#drop"><span class="hs-identifier hs-var">LBS.drop</span></a></span><span> </span><span class="annot"><span class="annottext">Int64
</span><a href="#local-6989586621680944130"><span class="hs-identifier hs-var">nameIndex</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944126"><span class="hs-identifier hs-var">nameTable</span></a></span><span>
</span><span id="line-281"></span><span>      </span><span class="annot"><span class="annottext">Get ByteString -&gt; ByteString -&gt; IO ByteString
forall a. Get a -&gt; ByteString -&gt; IO a
</span><a href="GHC.SysTools.Elf.html#runGetOrThrow"><span class="hs-identifier hs-var">runGetOrThrow</span></a></span><span> </span><span class="annot"><span class="annottext">Get ByteString
</span><a href="../../binary/src/Data.Binary.Get.html#getLazyByteStringNul"><span class="hs-identifier hs-var">getLazyByteStringNul</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944125"><span class="hs-identifier hs-var">bs'</span></a></span><span>
</span><span id="line-282"></span><span>
</span><span id="line-283"></span><span>    </span><span id="local-6989586621680944164"><span class="annot"><span class="annottext">action :: IO (Maybe Section)
</span><a href="#local-6989586621680944164"><span class="hs-identifier hs-var hs-var">action</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-284"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621680944116"><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621680944116"><span class="hs-identifier hs-var">nameIndex</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680944115"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944115"><span class="hs-identifier hs-var">bs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; IO (Word32, ByteString)
</span><a href="#local-6989586621680944142"><span class="hs-identifier hs-var">getEntryByIndex</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word64 -&gt; Word64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621680944166"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-285"></span><span>      </span><span id="local-6989586621680944114"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944114"><span class="hs-identifier hs-var">name</span></a></span></span><span>            </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int64 -&gt; IO ByteString
</span><a href="#local-6989586621680944131"><span class="hs-identifier hs-var">getEntryName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word32 -&gt; Int64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621680944116"><span class="hs-identifier hs-var">nameIndex</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-286"></span><span>      </span><span class="annot"><span class="annottext">Maybe Section -&gt; IO (Maybe Section)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Section -&gt; Maybe Section
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(Section -&gt; Maybe Section) -&gt; Section -&gt; Maybe Section
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; ByteString -&gt; Section
</span><a href="GHC.SysTools.Elf.html#Section"><span class="hs-identifier hs-var">Section</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944114"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944115"><span class="hs-identifier hs-var">bs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-287"></span><span>
</span><span id="line-288"></span><span>
</span><span id="line-289"></span><span class="hs-comment">-- | Find a section from its name. Return the section contents.</span><span>
</span><span id="line-290"></span><span class="hs-comment">--</span><span>
</span><span id="line-291"></span><span class="hs-comment">-- We do not perform any check on the section type.</span><span>
</span><span id="line-292"></span><span class="annot"><a href="GHC.SysTools.Elf.html#findSectionFromName"><span class="hs-identifier hs-type">findSectionFromName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-293"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.SysTools.Elf.html#ElfHeader"><span class="hs-identifier hs-type">ElfHeader</span></a></span><span>
</span><span id="line-294"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.SysTools.Elf.html#SectionTable"><span class="hs-identifier hs-type">SectionTable</span></a></span><span>
</span><span id="line-295"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-296"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-297"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-298"></span><span id="findSectionFromName"><span class="annot"><span class="annottext">findSectionFromName :: DynFlags
-&gt; ElfHeader
-&gt; SectionTable
-&gt; String
-&gt; ByteString
-&gt; IO (Maybe ByteString)
</span><a href="GHC.SysTools.Elf.html#findSectionFromName"><span class="hs-identifier hs-var hs-var">findSectionFromName</span></a></span></span><span> </span><span id="local-6989586621680944112"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944112"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621680944111"><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944111"><span class="hs-identifier hs-var">hdr</span></a></span></span><span> </span><span id="local-6989586621680944110"><span class="annot"><span class="annottext">SectionTable
</span><a href="#local-6989586621680944110"><span class="hs-identifier hs-var">secTable</span></a></span></span><span> </span><span id="local-6989586621680944109"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944109"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621680944108"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944108"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-299"></span><span>    </span><span class="annot"><span class="annottext">[Word64] -&gt; IO (Maybe ByteString)
</span><a href="#local-6989586621680944107"><span class="hs-identifier hs-var">rec</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Word64
</span><span class="hs-number">0</span></span><span class="hs-glyph">..</span><span class="annot"><span class="annottext">SectionTable -&gt; Word64
</span><a href="GHC.SysTools.Elf.html#sectionEntryCount"><span class="hs-identifier hs-var hs-var">sectionEntryCount</span></a></span><span> </span><span class="annot"><span class="annottext">SectionTable
</span><a href="#local-6989586621680944110"><span class="hs-identifier hs-var">secTable</span></a></span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; Word64 -&gt; Word64
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Word64
</span><span class="hs-number">1</span></span><span class="hs-special">]</span><span>
</span><span id="line-300"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-301"></span><span>    </span><span class="hs-comment">-- convert the required section name into a ByteString to perform</span><span>
</span><span id="line-302"></span><span>    </span><span class="hs-comment">-- ByteString comparison instead of String comparison</span><span>
</span><span id="line-303"></span><span>    </span><span id="local-6989586621680944106"><span class="annot"><span class="annottext">name' :: ByteString
</span><a href="#local-6989586621680944106"><span class="hs-identifier hs-var hs-var">name'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; ByteString
</span><a href="../../bytestring/src/Data.ByteString.Lazy.Char8.html#pack"><span class="hs-identifier hs-var">B8.pack</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944109"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-304"></span><span>
</span><span id="line-305"></span><span>    </span><span class="hs-comment">-- compare recursively each section name and return the contents of</span><span>
</span><span id="line-306"></span><span>    </span><span class="hs-comment">-- the matching one, if any</span><span>
</span><span id="line-307"></span><span>    </span><span id="local-6989586621680944107"><span class="annot"><span class="annottext">rec :: [Word64] -&gt; IO (Maybe ByteString)
</span><a href="#local-6989586621680944107"><span class="hs-identifier hs-var hs-var">rec</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe ByteString -&gt; IO (Maybe ByteString)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe ByteString
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-308"></span><span>    </span><span class="annot"><a href="#local-6989586621680944107"><span class="hs-identifier hs-var">rec</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680944099"><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621680944099"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680944098"><span class="annot"><span class="annottext">[Word64]
</span><a href="#local-6989586621680944098"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-309"></span><span>      </span><span id="local-6989586621680944097"><span class="annot"><span class="annottext">Maybe Section
</span><a href="#local-6989586621680944097"><span class="hs-identifier hs-var">me</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; ElfHeader
-&gt; SectionTable
-&gt; Word64
-&gt; ByteString
-&gt; IO (Maybe Section)
</span><a href="GHC.SysTools.Elf.html#readElfSectionByIndex"><span class="hs-identifier hs-var">readElfSectionByIndex</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944112"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944111"><span class="hs-identifier hs-var">hdr</span></a></span><span> </span><span class="annot"><span class="annottext">SectionTable
</span><a href="#local-6989586621680944110"><span class="hs-identifier hs-var">secTable</span></a></span><span> </span><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621680944099"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944108"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-310"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Section
</span><a href="#local-6989586621680944097"><span class="hs-identifier hs-var">me</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-311"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680944096"><span class="annot"><span class="annottext">Section
</span><a href="#local-6989586621680944096"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Section -&gt; ByteString
</span><a href="GHC.SysTools.Elf.html#entryName"><span class="hs-identifier hs-var hs-var">entryName</span></a></span><span> </span><span class="annot"><span class="annottext">Section
</span><a href="#local-6989586621680944096"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; ByteString -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944106"><span class="hs-identifier hs-var">name'</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe ByteString -&gt; IO (Maybe ByteString)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ByteString -&gt; Maybe ByteString
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Section -&gt; ByteString
</span><a href="GHC.SysTools.Elf.html#entryBS"><span class="hs-identifier hs-var hs-var">entryBS</span></a></span><span> </span><span class="annot"><span class="annottext">Section
</span><a href="#local-6989586621680944096"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-312"></span><span>        </span><span class="annot"><span class="annottext">Maybe Section
</span><span class="hs-identifier">_</span></span><span>                             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Word64] -&gt; IO (Maybe ByteString)
</span><a href="#local-6989586621680944107"><span class="hs-identifier hs-var">rec</span></a></span><span> </span><span class="annot"><span class="annottext">[Word64]
</span><a href="#local-6989586621680944098"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-313"></span><span>
</span><span id="line-314"></span><span>
</span><span id="line-315"></span><span class="hs-comment">-- | Given a section name, read its contents as a ByteString.</span><span>
</span><span id="line-316"></span><span class="hs-comment">--</span><span>
</span><span id="line-317"></span><span class="hs-comment">-- If the section isn't found or if there is any parsing error, we return</span><span>
</span><span id="line-318"></span><span class="hs-comment">-- Nothing</span><span>
</span><span id="line-319"></span><span class="annot"><a href="GHC.SysTools.Elf.html#readElfSectionByName"><span class="hs-identifier hs-type">readElfSectionByName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-320"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-321"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-322"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier hs-type">LBS.ByteString</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-323"></span><span>
</span><span id="line-324"></span><span id="readElfSectionByName"><span class="annot"><span class="annottext">readElfSectionByName :: DynFlags -&gt; ByteString -&gt; String -&gt; IO (Maybe ByteString)
</span><a href="GHC.SysTools.Elf.html#readElfSectionByName"><span class="hs-identifier hs-var hs-var">readElfSectionByName</span></a></span></span><span> </span><span id="local-6989586621680944095"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944095"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621680944094"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944094"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span id="local-6989586621680944093"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944093"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO (Maybe ByteString)
</span><a href="#local-6989586621680944092"><span class="hs-identifier hs-var">action</span></a></span><span> </span><span class="annot"><span class="annottext">IO (Maybe ByteString)
-&gt; (IOException -&gt; IO (Maybe ByteString)) -&gt; IO (Maybe ByteString)
forall a. IO a -&gt; (IOException -&gt; IO a) -&gt; IO a
</span><a href="GHC.Utils.Exception.html#catchIO"><span class="hs-operator hs-var">`catchIO`</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">IOException
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-325"></span><span>    </span><span class="annot"><span class="annottext">DynFlags -&gt; Int -&gt; MsgDoc -&gt; IO ()
</span><a href="GHC.Utils.Error.html#debugTraceMsg"><span class="hs-identifier hs-var">debugTraceMsg</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944095"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; IO ()) -&gt; MsgDoc -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-326"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Unable to read ELF section \&quot;&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944093"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\&quot;&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-327"></span><span>    </span><span class="annot"><span class="annottext">Maybe ByteString -&gt; IO (Maybe ByteString)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe ByteString
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-328"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-329"></span><span>    </span><span id="local-6989586621680944092"><span class="annot"><span class="annottext">action :: IO (Maybe ByteString)
</span><a href="#local-6989586621680944092"><span class="hs-identifier hs-var hs-var">action</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MaybeT IO ByteString -&gt; IO (Maybe ByteString)
forall (m :: * -&gt; *) a. MaybeT m a -&gt; m (Maybe a)
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#runMaybeT"><span class="hs-identifier hs-var hs-var">runMaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">(MaybeT IO ByteString -&gt; IO (Maybe ByteString))
-&gt; MaybeT IO ByteString -&gt; IO (Maybe ByteString)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-330"></span><span>      </span><span id="local-6989586621680944087"><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944087"><span class="hs-identifier hs-var">hdr</span></a></span></span><span>      </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO (Maybe ElfHeader) -&gt; MaybeT IO ElfHeader
forall (m :: * -&gt; *) a. m (Maybe a) -&gt; MaybeT m a
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-var">MaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">(IO (Maybe ElfHeader) -&gt; MaybeT IO ElfHeader)
-&gt; IO (Maybe ElfHeader) -&gt; MaybeT IO ElfHeader
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; ByteString -&gt; IO (Maybe ElfHeader)
</span><a href="GHC.SysTools.Elf.html#readElfHeader"><span class="hs-identifier hs-var">readElfHeader</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944095"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944094"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-331"></span><span>      </span><span id="local-6989586621680944085"><span class="annot"><span class="annottext">SectionTable
</span><a href="#local-6989586621680944085"><span class="hs-identifier hs-var">secTable</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO (Maybe SectionTable) -&gt; MaybeT IO SectionTable
forall (m :: * -&gt; *) a. m (Maybe a) -&gt; MaybeT m a
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-var">MaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">(IO (Maybe SectionTable) -&gt; MaybeT IO SectionTable)
-&gt; IO (Maybe SectionTable) -&gt; MaybeT IO SectionTable
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; ElfHeader -&gt; ByteString -&gt; IO (Maybe SectionTable)
</span><a href="GHC.SysTools.Elf.html#readElfSectionTable"><span class="hs-identifier hs-var">readElfSectionTable</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944095"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944087"><span class="hs-identifier hs-var">hdr</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944094"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-332"></span><span>      </span><span class="annot"><span class="annottext">IO (Maybe ByteString) -&gt; MaybeT IO ByteString
forall (m :: * -&gt; *) a. m (Maybe a) -&gt; MaybeT m a
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-var">MaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">(IO (Maybe ByteString) -&gt; MaybeT IO ByteString)
-&gt; IO (Maybe ByteString) -&gt; MaybeT IO ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; ElfHeader
-&gt; SectionTable
-&gt; String
-&gt; ByteString
-&gt; IO (Maybe ByteString)
</span><a href="GHC.SysTools.Elf.html#findSectionFromName"><span class="hs-identifier hs-var">findSectionFromName</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944095"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944087"><span class="hs-identifier hs-var">hdr</span></a></span><span> </span><span class="annot"><span class="annottext">SectionTable
</span><a href="#local-6989586621680944085"><span class="hs-identifier hs-var">secTable</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944093"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944094"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-333"></span><span>
</span><span id="line-334"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-335"></span><span class="hs-comment">-- NOTE SECTIONS</span><span>
</span><span id="line-336"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-337"></span><span>
</span><span id="line-338"></span><span class="hs-comment">-- | read a Note as a ByteString</span><span>
</span><span id="line-339"></span><span class="hs-comment">--</span><span>
</span><span id="line-340"></span><span class="hs-comment">-- If you try to read a note from a section which does not support the Note</span><span>
</span><span id="line-341"></span><span class="hs-comment">-- format, the parsing is likely to fail and Nothing will be returned</span><span>
</span><span id="line-342"></span><span class="annot"><a href="GHC.SysTools.Elf.html#readElfNoteBS"><span class="hs-identifier hs-type">readElfNoteBS</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-343"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-344"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-345"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-346"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier hs-type">LBS.ByteString</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-347"></span><span>
</span><span id="line-348"></span><span id="readElfNoteBS"><span class="annot"><span class="annottext">readElfNoteBS :: DynFlags -&gt; ByteString -&gt; String -&gt; String -&gt; IO (Maybe ByteString)
</span><a href="GHC.SysTools.Elf.html#readElfNoteBS"><span class="hs-identifier hs-var hs-var">readElfNoteBS</span></a></span></span><span> </span><span id="local-6989586621680944083"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944083"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621680944082"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944082"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span id="local-6989586621680944081"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944081"><span class="hs-identifier hs-var">sectionName</span></a></span></span><span> </span><span id="local-6989586621680944080"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944080"><span class="hs-identifier hs-var">noteId</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO (Maybe ByteString)
</span><a href="#local-6989586621680944079"><span class="hs-identifier hs-var">action</span></a></span><span> </span><span class="annot"><span class="annottext">IO (Maybe ByteString)
-&gt; (IOException -&gt; IO (Maybe ByteString)) -&gt; IO (Maybe ByteString)
forall a. IO a -&gt; (IOException -&gt; IO a) -&gt; IO a
</span><a href="GHC.Utils.Exception.html#catchIO"><span class="hs-operator hs-var">`catchIO`</span></a></span><span>  </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">IOException
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-349"></span><span>    </span><span class="annot"><span class="annottext">DynFlags -&gt; Int -&gt; MsgDoc -&gt; IO ()
</span><a href="GHC.Utils.Error.html#debugTraceMsg"><span class="hs-identifier hs-var">debugTraceMsg</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944083"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; IO ()) -&gt; MsgDoc -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-350"></span><span>         </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Unable to read ELF note \&quot;&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944080"><span class="hs-identifier hs-var">noteId</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span>
</span><span id="line-351"></span><span>               </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\&quot; in section \&quot;&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944081"><span class="hs-identifier hs-var">sectionName</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\&quot;&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-352"></span><span>    </span><span class="annot"><span class="annottext">Maybe ByteString -&gt; IO (Maybe ByteString)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe ByteString
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-353"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-354"></span><span>    </span><span class="hs-comment">-- align the getter on n bytes</span><span>
</span><span id="line-355"></span><span>    </span><span id="local-6989586621680944071"><span class="annot"><span class="annottext">align :: Int64 -&gt; Get ()
</span><a href="#local-6989586621680944071"><span class="hs-identifier hs-var hs-var">align</span></a></span></span><span> </span><span id="local-6989586621680944070"><span class="annot"><span class="annottext">Int64
</span><a href="#local-6989586621680944070"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-356"></span><span>      </span><span id="local-6989586621680944069"><span class="annot"><span class="annottext">Int64
</span><a href="#local-6989586621680944069"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Get Int64
</span><a href="../../binary/src/Data.Binary.Get.Internal.html#bytesRead"><span class="hs-identifier hs-var">bytesRead</span></a></span><span>
</span><span id="line-357"></span><span>      </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int64
</span><a href="#local-6989586621680944069"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">Int64 -&gt; Int64 -&gt; Int64
forall a. Integral a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#mod"><span class="hs-operator hs-var">`mod`</span></a></span><span> </span><span class="annot"><span class="annottext">Int64
</span><a href="#local-6989586621680944070"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int64 -&gt; Int64 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int64
</span><span class="hs-number">0</span></span><span>
</span><span id="line-358"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">() -&gt; Get ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-359"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Get ()
</span><a href="../../binary/src/Data.Binary.Get.html#skip"><span class="hs-identifier hs-var">skip</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">Get () -&gt; Get () -&gt; Get ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int64 -&gt; Get ()
</span><a href="#local-6989586621680944071"><span class="hs-identifier hs-var">align</span></a></span><span> </span><span class="annot"><span class="annottext">Int64
</span><a href="#local-6989586621680944070"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-360"></span><span>
</span><span id="line-361"></span><span>    </span><span class="hs-comment">-- noteId as a bytestring</span><span>
</span><span id="line-362"></span><span>    </span><span id="local-6989586621680944066"><span class="annot"><span class="annottext">noteId' :: ByteString
</span><a href="#local-6989586621680944066"><span class="hs-identifier hs-var hs-var">noteId'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; ByteString
</span><a href="../../bytestring/src/Data.ByteString.Lazy.Char8.html#pack"><span class="hs-identifier hs-var">B8.pack</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944080"><span class="hs-identifier hs-var">noteId</span></a></span><span>
</span><span id="line-363"></span><span>
</span><span id="line-364"></span><span>    </span><span class="hs-comment">-- read notes recursively until the one with a valid identifier is found</span><span>
</span><span id="line-365"></span><span>    </span><span id="local-6989586621680944046"><span class="annot"><span class="annottext">findNote :: ElfHeader -&gt; Get (Maybe ByteString)
</span><a href="#local-6989586621680944046"><span class="hs-identifier hs-var hs-var">findNote</span></a></span></span><span> </span><span id="local-6989586621680944045"><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944045"><span class="hs-identifier hs-var">hdr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-366"></span><span>      </span><span class="annot"><span class="annottext">Int64 -&gt; Get ()
</span><a href="#local-6989586621680944071"><span class="hs-identifier hs-var">align</span></a></span><span> </span><span class="annot"><span class="annottext">Int64
</span><span class="hs-number">4</span></span><span>
</span><span id="line-367"></span><span>      </span><span id="local-6989586621680944044"><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621680944044"><span class="hs-identifier hs-var">namesz</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ElfHeader -&gt; Get Word32
</span><a href="GHC.SysTools.Elf.html#gw32"><span class="hs-identifier hs-var hs-var">gw32</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944045"><span class="hs-identifier hs-var">hdr</span></a></span><span>
</span><span id="line-368"></span><span>      </span><span id="local-6989586621680944043"><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621680944043"><span class="hs-identifier hs-var">descsz</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ElfHeader -&gt; Get Word32
</span><a href="GHC.SysTools.Elf.html#gw32"><span class="hs-identifier hs-var hs-var">gw32</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944045"><span class="hs-identifier hs-var">hdr</span></a></span><span>
</span><span id="line-369"></span><span>      </span><span class="annot"><span class="annottext">Word32
</span><span class="hs-identifier">_</span></span><span>      </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ElfHeader -&gt; Get Word32
</span><a href="GHC.SysTools.Elf.html#gw32"><span class="hs-identifier hs-var hs-var">gw32</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944045"><span class="hs-identifier hs-var">hdr</span></a></span><span> </span><span class="hs-comment">-- we don't use the note type</span><span>
</span><span id="line-370"></span><span>      </span><span id="local-6989586621680944042"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944042"><span class="hs-identifier hs-var">name</span></a></span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621680944044"><span class="hs-identifier hs-var">namesz</span></a></span><span> </span><span class="annot"><span class="annottext">Word32 -&gt; Word32 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Word32
</span><span class="hs-number">0</span></span><span>
</span><span id="line-371"></span><span>                  </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; Get ByteString
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="../../bytestring/src/Data.ByteString.Lazy.html#empty"><span class="hs-identifier hs-var">LBS.empty</span></a></span><span>
</span><span id="line-372"></span><span>                  </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Get ByteString
</span><a href="../../binary/src/Data.Binary.Get.html#getLazyByteStringNul"><span class="hs-identifier hs-var">getLazyByteStringNul</span></a></span><span>
</span><span id="line-373"></span><span>      </span><span class="annot"><span class="annottext">Int64 -&gt; Get ()
</span><a href="#local-6989586621680944071"><span class="hs-identifier hs-var">align</span></a></span><span> </span><span class="annot"><span class="annottext">Int64
</span><span class="hs-number">4</span></span><span>
</span><span id="line-374"></span><span>      </span><span id="local-6989586621680944040"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944040"><span class="hs-identifier hs-var">desc</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621680944043"><span class="hs-identifier hs-var">descsz</span></a></span><span> </span><span class="annot"><span class="annottext">Word32 -&gt; Word32 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Word32
</span><span class="hs-number">0</span></span><span>
</span><span id="line-375"></span><span>                  </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; Get ByteString
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="../../bytestring/src/Data.ByteString.Lazy.html#empty"><span class="hs-identifier hs-var">LBS.empty</span></a></span><span>
</span><span id="line-376"></span><span>                  </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Int64 -&gt; Get ByteString
</span><a href="../../binary/src/Data.Binary.Get.html#getLazyByteString"><span class="hs-identifier hs-var">getLazyByteString</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word32 -&gt; Int64
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621680944043"><span class="hs-identifier hs-var">descsz</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-377"></span><span>      </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944042"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; ByteString -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944066"><span class="hs-identifier hs-var">noteId'</span></a></span><span>
</span><span id="line-378"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe ByteString -&gt; Get (Maybe ByteString)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe ByteString -&gt; Get (Maybe ByteString))
-&gt; Maybe ByteString -&gt; Get (Maybe ByteString)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; Maybe ByteString
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944040"><span class="hs-identifier hs-var">desc</span></a></span><span>
</span><span id="line-379"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">ElfHeader -&gt; Get (Maybe ByteString)
</span><a href="#local-6989586621680944046"><span class="hs-identifier hs-var">findNote</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944045"><span class="hs-identifier hs-var">hdr</span></a></span><span>
</span><span id="line-380"></span><span>
</span><span id="line-381"></span><span>
</span><span id="line-382"></span><span>    </span><span id="local-6989586621680944079"><span class="annot"><span class="annottext">action :: IO (Maybe ByteString)
</span><a href="#local-6989586621680944079"><span class="hs-identifier hs-var hs-var">action</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MaybeT IO ByteString -&gt; IO (Maybe ByteString)
forall (m :: * -&gt; *) a. MaybeT m a -&gt; m (Maybe a)
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#runMaybeT"><span class="hs-identifier hs-var hs-var">runMaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">(MaybeT IO ByteString -&gt; IO (Maybe ByteString))
-&gt; MaybeT IO ByteString -&gt; IO (Maybe ByteString)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-383"></span><span>      </span><span id="local-6989586621680944035"><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944035"><span class="hs-identifier hs-var">hdr</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO (Maybe ElfHeader) -&gt; MaybeT IO ElfHeader
forall (m :: * -&gt; *) a. m (Maybe a) -&gt; MaybeT m a
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-var">MaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">(IO (Maybe ElfHeader) -&gt; MaybeT IO ElfHeader)
-&gt; IO (Maybe ElfHeader) -&gt; MaybeT IO ElfHeader
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; ByteString -&gt; IO (Maybe ElfHeader)
</span><a href="GHC.SysTools.Elf.html#readElfHeader"><span class="hs-identifier hs-var">readElfHeader</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944083"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944082"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-384"></span><span>      </span><span id="local-6989586621680944034"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944034"><span class="hs-identifier hs-var">sec</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO (Maybe ByteString) -&gt; MaybeT IO ByteString
forall (m :: * -&gt; *) a. m (Maybe a) -&gt; MaybeT m a
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-var">MaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">(IO (Maybe ByteString) -&gt; MaybeT IO ByteString)
-&gt; IO (Maybe ByteString) -&gt; MaybeT IO ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; ByteString -&gt; String -&gt; IO (Maybe ByteString)
</span><a href="GHC.SysTools.Elf.html#readElfSectionByName"><span class="hs-identifier hs-var">readElfSectionByName</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944083"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944082"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944081"><span class="hs-identifier hs-var">sectionName</span></a></span><span>
</span><span id="line-385"></span><span>      </span><span class="annot"><span class="annottext">IO (Maybe ByteString) -&gt; MaybeT IO ByteString
forall (m :: * -&gt; *) a. m (Maybe a) -&gt; MaybeT m a
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-var">MaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">(IO (Maybe ByteString) -&gt; MaybeT IO ByteString)
-&gt; IO (Maybe ByteString) -&gt; MaybeT IO ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Get (Maybe ByteString) -&gt; ByteString -&gt; IO (Maybe ByteString)
forall a. Get a -&gt; ByteString -&gt; IO a
</span><a href="GHC.SysTools.Elf.html#runGetOrThrow"><span class="hs-identifier hs-var">runGetOrThrow</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ElfHeader -&gt; Get (Maybe ByteString)
</span><a href="#local-6989586621680944046"><span class="hs-identifier hs-var">findNote</span></a></span><span> </span><span class="annot"><span class="annottext">ElfHeader
</span><a href="#local-6989586621680944035"><span class="hs-identifier hs-var">hdr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944034"><span class="hs-identifier hs-var">sec</span></a></span><span>
</span><span id="line-386"></span><span>
</span><span id="line-387"></span><span class="hs-comment">-- | read a Note as a String</span><span>
</span><span id="line-388"></span><span class="hs-comment">--</span><span>
</span><span id="line-389"></span><span class="hs-comment">-- If you try to read a note from a section which does not support the Note</span><span>
</span><span id="line-390"></span><span class="hs-comment">-- format, the parsing is likely to fail and Nothing will be returned</span><span>
</span><span id="line-391"></span><span class="annot"><a href="GHC.SysTools.Elf.html#readElfNoteAsString"><span class="hs-identifier hs-type">readElfNoteAsString</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-392"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-393"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-394"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-395"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-396"></span><span>
</span><span id="line-397"></span><span id="readElfNoteAsString"><span class="annot"><span class="annottext">readElfNoteAsString :: DynFlags -&gt; String -&gt; String -&gt; String -&gt; IO (Maybe String)
</span><a href="GHC.SysTools.Elf.html#readElfNoteAsString"><span class="hs-identifier hs-var hs-var">readElfNoteAsString</span></a></span></span><span> </span><span id="local-6989586621680944032"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944032"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621680944031"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944031"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span id="local-6989586621680944030"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944030"><span class="hs-identifier hs-var">sectionName</span></a></span></span><span> </span><span id="local-6989586621680944029"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944029"><span class="hs-identifier hs-var">noteId</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO (Maybe String)
</span><a href="#local-6989586621680944028"><span class="hs-identifier hs-var">action</span></a></span><span> </span><span class="annot"><span class="annottext">IO (Maybe String)
-&gt; (IOException -&gt; IO (Maybe String)) -&gt; IO (Maybe String)
forall a. IO a -&gt; (IOException -&gt; IO a) -&gt; IO a
</span><a href="GHC.Utils.Exception.html#catchIO"><span class="hs-operator hs-var">`catchIO`</span></a></span><span>  </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">IOException
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-398"></span><span>    </span><span class="annot"><span class="annottext">DynFlags -&gt; Int -&gt; MsgDoc -&gt; IO ()
</span><a href="GHC.Utils.Error.html#debugTraceMsg"><span class="hs-identifier hs-var">debugTraceMsg</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944032"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; IO ()) -&gt; MsgDoc -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-399"></span><span>         </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Unable to read ELF note \&quot;&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944029"><span class="hs-identifier hs-var">noteId</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span>
</span><span id="line-400"></span><span>               </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\&quot; in section \&quot;&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944030"><span class="hs-identifier hs-var">sectionName</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\&quot;&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-401"></span><span>    </span><span class="annot"><span class="annottext">Maybe String -&gt; IO (Maybe String)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe String
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-402"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-403"></span><span>    </span><span id="local-6989586621680944028"><span class="annot"><span class="annottext">action :: IO (Maybe String)
</span><a href="#local-6989586621680944028"><span class="hs-identifier hs-var hs-var">action</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-404"></span><span>      </span><span id="local-6989586621680944022"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944022"><span class="hs-identifier hs-var">bs</span></a></span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO ByteString
</span><a href="../../bytestring/src/Data.ByteString.Lazy.html#readFile"><span class="hs-identifier hs-var">LBS.readFile</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944031"><span class="hs-identifier hs-var">path</span></a></span><span>
</span><span id="line-405"></span><span>      </span><span id="local-6989586621680944020"><span class="annot"><span class="annottext">Maybe ByteString
</span><a href="#local-6989586621680944020"><span class="hs-identifier hs-var">note</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; ByteString -&gt; String -&gt; String -&gt; IO (Maybe ByteString)
</span><a href="GHC.SysTools.Elf.html#readElfNoteBS"><span class="hs-identifier hs-var">readElfNoteBS</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680944032"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944022"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944030"><span class="hs-identifier hs-var">sectionName</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944029"><span class="hs-identifier hs-var">noteId</span></a></span><span>
</span><span id="line-406"></span><span>      </span><span class="annot"><span class="annottext">Maybe String -&gt; IO (Maybe String)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(ByteString -&gt; String) -&gt; Maybe ByteString -&gt; Maybe String
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; String
</span><a href="../../bytestring/src/Data.ByteString.Lazy.Char8.html#unpack"><span class="hs-identifier hs-var">B8.unpack</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe ByteString
</span><a href="#local-6989586621680944020"><span class="hs-identifier hs-var">note</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-407"></span><span>
</span><span id="line-408"></span><span>
</span><span id="line-409"></span><span class="hs-comment">-- | Generate the GAS code to create a Note section</span><span>
</span><span id="line-410"></span><span class="hs-comment">--</span><span>
</span><span id="line-411"></span><span class="hs-comment">-- Header fields for notes are 32-bit long (see Note [ELF specification]).</span><span>
</span><span id="line-412"></span><span class="annot"><a href="GHC.SysTools.Elf.html#makeElfNote"><span class="hs-identifier hs-type">makeElfNote</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word32"><span class="hs-identifier hs-type">Word32</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-413"></span><span id="makeElfNote"><span class="annot"><span class="annottext">makeElfNote :: Platform -&gt; String -&gt; String -&gt; Word32 -&gt; String -&gt; MsgDoc
</span><a href="GHC.SysTools.Elf.html#makeElfNote"><span class="hs-identifier hs-var hs-var">makeElfNote</span></a></span></span><span> </span><span id="local-6989586621680944018"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621680944018"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621680944017"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944017"><span class="hs-identifier hs-var">sectionName</span></a></span></span><span> </span><span id="local-6989586621680944016"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944016"><span class="hs-identifier hs-var">noteName</span></a></span></span><span> </span><span id="local-6989586621680944015"><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621680944015"><span class="hs-identifier hs-var">typ</span></a></span></span><span> </span><span id="local-6989586621680944014"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944014"><span class="hs-identifier hs-var">contents</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#hcat"><span class="hs-identifier hs-var">hcat</span></a></span><span> </span><span class="hs-special">[</span><span>
</span><span id="line-414"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\t.section &quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-415"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944017"><span class="hs-identifier hs-var">sectionName</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-416"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;,\&quot;\&quot;,&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-417"></span><span>    </span><span class="annot"><span class="annottext">Platform -&gt; String -&gt; MsgDoc
</span><a href="GHC.Utils.Asm.html#sectionType"><span class="hs-identifier hs-var">sectionType</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621680944018"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;note&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-418"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\n&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-419"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\t.balign 4\n&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-420"></span><span>
</span><span id="line-421"></span><span>    </span><span class="hs-comment">-- note name length (+ 1 for ending \0)</span><span>
</span><span id="line-422"></span><span>    </span><span class="annot"><span class="annottext">Int -&gt; MsgDoc
forall a. Show a =&gt; a -&gt; MsgDoc
</span><a href="#local-6989586621680944012"><span class="hs-identifier hs-var">asWord32</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944016"><span class="hs-identifier hs-var">noteName</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-423"></span><span>
</span><span id="line-424"></span><span>    </span><span class="hs-comment">-- note contents size</span><span>
</span><span id="line-425"></span><span>    </span><span class="annot"><span class="annottext">Int -&gt; MsgDoc
forall a. Show a =&gt; a -&gt; MsgDoc
</span><a href="#local-6989586621680944012"><span class="hs-identifier hs-var">asWord32</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944014"><span class="hs-identifier hs-var">contents</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-426"></span><span>
</span><span id="line-427"></span><span>    </span><span class="hs-comment">-- note type</span><span>
</span><span id="line-428"></span><span>    </span><span class="annot"><span class="annottext">Word32 -&gt; MsgDoc
forall a. Show a =&gt; a -&gt; MsgDoc
</span><a href="#local-6989586621680944012"><span class="hs-identifier hs-var">asWord32</span></a></span><span> </span><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621680944015"><span class="hs-identifier hs-var">typ</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-429"></span><span>
</span><span id="line-430"></span><span>    </span><span class="hs-comment">-- note name (.asciz for \0 ending string) + padding</span><span>
</span><span id="line-431"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\t.asciz \&quot;&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-432"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944016"><span class="hs-identifier hs-var">noteName</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-433"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\&quot;\n&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-434"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\t.balign 4\n&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-435"></span><span>
</span><span id="line-436"></span><span>    </span><span class="hs-comment">-- note contents (.ascii to avoid ending \0) + padding</span><span>
</span><span id="line-437"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\t.ascii \&quot;&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-438"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; String
</span><a href="#local-6989586621680944010"><span class="hs-identifier hs-var">escape</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680944014"><span class="hs-identifier hs-var">contents</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-439"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\&quot;\n&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-440"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\t.balign 4\n&quot;</span></span><span class="hs-special">]</span><span>
</span><span id="line-441"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-442"></span><span>    </span><span class="annot"><a href="#local-6989586621680944010"><span class="hs-identifier hs-type">escape</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-443"></span><span>    </span><span id="local-6989586621680944010"><span class="annot"><span class="annottext">escape :: String -&gt; String
</span><a href="#local-6989586621680944010"><span class="hs-identifier hs-var hs-var">escape</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Char -&gt; String) -&gt; String -&gt; String
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8 -&gt; String
</span><a href="GHC.Utils.Misc.html#charToC"><span class="hs-identifier hs-var">charToC</span></a></span><span class="annot"><span class="annottext">(Word8 -&gt; String) -&gt; (Char -&gt; Word8) -&gt; Char -&gt; String
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span class="annot"><span class="annottext">Int -&gt; Word8
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span class="annot"><span class="annottext">(Int -&gt; Word8) -&gt; (Char -&gt; Int) -&gt; Char -&gt; Word8
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="../../base/src/GHC.Base.html#ord"><span class="hs-identifier hs-var">ord</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-444"></span><span>
</span><span id="line-445"></span><span>    </span><span id="local-6989586621680944375"><span class="annot"><a href="#local-6989586621680944012"><span class="hs-identifier hs-type">asWord32</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Show.html#Show"><span class="hs-identifier hs-type">Show</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680944375"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680944375"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span></span><span>
</span><span id="line-446"></span><span>    </span><span id="local-6989586621680944012"><span class="annot"><span class="annottext">asWord32 :: forall a. Show a =&gt; a -&gt; MsgDoc
</span><a href="#local-6989586621680944012"><span class="hs-identifier hs-var hs-var">asWord32</span></a></span></span><span> </span><span id="local-6989586621680944006"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680944006"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#hcat"><span class="hs-identifier hs-var">hcat</span></a></span><span> </span><span class="hs-special">[</span><span>
</span><span id="line-447"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\t.4byte &quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-448"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680944006"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-449"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\n&quot;</span></span><span class="hs-special">]</span><span>
</span><span id="line-450"></span><span>
</span><span id="line-451"></span><span>
</span><span id="line-452"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-453"></span><span class="hs-comment">-- Helpers</span><span>
</span><span id="line-454"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-455"></span><span>
</span><span id="line-456"></span><span class="hs-comment">-- | runGet in IO monad that throws an IOException on failure</span><span>
</span><span id="line-457"></span><span id="local-6989586621680944411"><span class="annot"><a href="GHC.SysTools.Elf.html#runGetOrThrow"><span class="hs-identifier hs-type">runGetOrThrow</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../binary/src/Data.Binary.Get.Internal.html#Get"><span class="hs-identifier hs-type">Get</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680944411"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier hs-type">LBS.ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621680944411"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-458"></span><span id="runGetOrThrow"><span class="annot"><span class="annottext">runGetOrThrow :: forall a. Get a -&gt; ByteString -&gt; IO a
</span><a href="GHC.SysTools.Elf.html#runGetOrThrow"><span class="hs-identifier hs-var hs-var">runGetOrThrow</span></a></span></span><span> </span><span id="local-6989586621680944001"><span class="annot"><span class="annottext">Get a
</span><a href="#local-6989586621680944001"><span class="hs-identifier hs-var">g</span></a></span></span><span> </span><span id="local-6989586621680944000"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944000"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Get a
-&gt; ByteString
-&gt; Either (ByteString, Int64, String) (ByteString, Int64, a)
forall a.
Get a
-&gt; ByteString
-&gt; Either (ByteString, Int64, String) (ByteString, Int64, a)
</span><a href="../../binary/src/Data.Binary.Get.html#runGetOrFail"><span class="hs-identifier hs-var">runGetOrFail</span></a></span><span> </span><span class="annot"><span class="annottext">Get a
</span><a href="#local-6989586621680944001"><span class="hs-identifier hs-var">g</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680944000"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-459"></span><span>  </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span class="annot"><span class="annottext">(ByteString, Int64, String)
</span><span class="hs-identifier">_</span></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO a
forall (m :: * -&gt; *) a. MonadFail m =&gt; String -&gt; m a
</span><a href="../../base/src/Control.Monad.Fail.html#fail"><span class="hs-identifier hs-var">fail</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Error while reading file&quot;</span></span><span>
</span><span id="line-460"></span><span>  </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ByteString
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Int64
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621680943998"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680943998"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">a -&gt; IO a
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680943998"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-461"></span></pre></body></html>